colorAdminApp.service('passwordService',function() {
   	    this.checkPassword=function(password){
		var retVal=true;
		if(this.checkLength(password)==false){
			$(".p1").css({"color":"red"});
			retVal=false;
		}else{
			$(".p1").css({"color":"green"});
		}
		if(this.checkHasUpperCase(password)==false){
			retVal=false;
			$(".p2").css({"color":"red"});
		}else{
			$(".p2").css({"color":"green"});
		}
		if(this.checkHasLowerCase(password)==false){
			retVal=false;
			$(".p3").css({"color":"red"});
		}else{
			$(".p3").css({"color":"green"});
		}
		if(this.checkHasNumber(password)==false){
			retVal=false;
			$(".p4").css({"color":"red"});
		}else{
			$(".p4").css({"color":"green"});
		}
		if(this.checkHasSpecialChar(password)==false){
			retVal=false;
			$(".p5").css({"color":"red"});
		}else{
			$(".p5").css({"color":"green"});
		}
		return retVal;
	}
	this.doCheckPassword=function (password, reg) {
		var pattern=new RegExp(reg);
		return pattern.test(password);
	}
    this.checkHasSpecialChar=function(password){
		var reg="[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]";
		return this.doCheckPassword(password, reg);
	}
	this.checkHasLowerCase=function (password){
		var reg="[a-z]";
		return this.doCheckPassword(password, reg);
	}
	this.checkHasUpperCase=function (password){
		var reg="[A-Z]";
		return this.doCheckPassword(password, reg);
	}
	this.checkHasNumber=function (password){
		var reg="[0-9]";
		return this.doCheckPassword(password, reg);
	}

	this.checkLength=function (password){
		var length=password.length;
		if(length<8||length>12){
			return false;
		}
		return true;
	}
	
	 this.checkNewPassword=function(password){
		    var checkPasswordResult=this.checkPassword(password);
			if(checkPasswordResult==false){
				$("#newPasswordPopover").show();
			}else{
				$("#newPasswordPopover").hide();
			}
		 return checkPasswordResult;
	 }
	 
	 this.checkConfirmNewPassword=function(newPassword,confirmNewPassword){
		    if(newPassword!=confirmNewPassword){
				$("#confirmNewPasswordPopvoer").show();
				return false;
			}else{
				$("#confirmNewPasswordPopvoer").hide();
			}
		 return true ;
	 }
	
});